﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Antlr.Runtime;
using System.Collections;

namespace ANTLRTest.Context
{
    public class ContextSequence
    {
        #region Constructor

        internal ContextSequence(ContextWalker walker, string baseText, string baseRule)
        {
            this.Walker = walker;
            
            Antlr.Runtime.ICharStream st = new Antlr.Runtime.ANTLRStringStream(baseText);
            Lexer lexer = Activator.CreateInstance(walker.LexerType, st) as Lexer;
            if (lexer == null) throw new Exception("Can not create lexer");
            this.stream = new TokenRewriteStream() { TokenSource = lexer };

            this.currentRule = baseRule;
            this.currentStreamTokenIndex = 0;
        }

        #endregion

        #region Private members

        private void ParseInput()
        {
            IList tokens = stream.GetTokens();
            for (int i = currentStreamTokenIndex; i < tokens.Count; i++)
            {
                
            }
        }

        #endregion

        #region Properties

        public ContextWalker Walker { get; private set; }

        #endregion

        private string currentRule;
        private TokenRewriteStream stream;
        private int currentStreamTokenIndex;
    }
}
